<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>SMS Massivi TOM</title>

	  <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
	  <link rel="stylesheet"  href="jquery.mobile/jquery.mobile-1.1.0.css" />
	  <script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script>
	  <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script>
	  <Script src="smsplugin.js" type="text/javascript" ></script>
	  <script type="text/javascript" charset="utf-8">
      
        var onDeviceReady = function() {
        	m=1;
			$('#send').bind('click', function () {
				alert('Phone: ' + $('#phone').val() + ' Message: ' + $('#message').val() + ' Invierò: '+ $('#numeroc').val());
				for (i=1; i<=$('#numeroc').val(); i++) { 
					window.plugins.sms.send($('#phone').val(), 
	                    $('#message').val()+ i, 
	                    function () { 
						    alert('Message sent successfully');
	                    	document.getElementById("inviati").innerHTML  = 'Inviati: '+ m++;
					    },
	    				function (e) {
	    					alert('Message Failed:' + e);
	    				}
					);
				}
			});  
        };

        function init() {
            document.addEventListener("deviceready", onDeviceReady, true);
        }   
</script>  

  </head>
  <body onload="init();" id="stage" class="theme">
    <div id="startPage" data-role="page" data-theme="a">
			<div data-role="header">
				<h1>SMS Massivi TOM</h1>
			</div>
			<div data-role="content">
				<label for="phone">Numero Destinatario:</label>
				<input type="tel" id="phone" name="phone" value='3803685088' placeholder="SMS Number"/>
				<label for="message">Messaggio:</label>
				<textarea id="message" name="message">ciao</textarea>
				<input type="number" id="numeroc" name="numeroc" placeholder="Quanti messaggi invio"/>
				<label for="inviati" id="inviati">Inviati:</label>		
				<a href="#" id="send" data-role="button">Invia</a>		
			</div>
		</div>
  </body>
</html>
